package com.mytx.zuul.filter;

import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpRequestDecorator;
import org.springframework.lang.Nullable;
import reactor.core.publisher.Flux;

@Deprecated
public class MyServerHttpRequestDecorator extends ServerHttpRequestDecorator {
    private Flux<DataBuffer> bufferFlux;
    private HttpHeaders httpHeaders=new HttpHeaders();

    public MyServerHttpRequestDecorator(ServerHttpRequest delegate) {
        super(delegate);
        httpHeaders.addAll(delegate.getHeaders());
    }

    @Override
    public HttpHeaders getHeaders() {
        return httpHeaders;
    }

    @Override
    public Flux<DataBuffer> getBody() {
        return bufferFlux;
    }


    public void setBufferFlux(Flux<DataBuffer> bufferFlux) {
        this.bufferFlux = bufferFlux;
    }

    public void addHeader(String headerName, @Nullable String headerValue){
        httpHeaders.set(headerName,headerValue);
    }
}
